package mysql

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"time"
)

var DB *gorm.DB

func init() {
	var err error
	dsn := "root:123456@tcp(120.27.208.86:3305)/2109A?charset=utf8mb4&parseTime=True&loc=Local"
	DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		return
	}
	err = DB.AutoMigrate(&Goods{}, &Order{})
	if err != nil {
		return
	}
}

type Goods struct {
	gorm.Model
	GoodsName      string
	GoodsPrice     float64
	GoodsInventory int
	GoodsViews     string
}

type Order struct {
	OrderId         int
	UserId          int
	GoodsId         int
	GoodsName       string
	OrderDate       time.Time
	ShippingAddress string
	TotalAmount     float64
}
